using System;
using System.ComponentModel;
using System.Windows.Controls;
using Microsoft.Practices.ServiceLocation;

namespace PrismNavigationFramework.Navigation.Controls
{
    public class PrismNavigationSecondaryFrame : ItemsControl, INavigate
    {
        private static bool IsDesignTime
        {
            get
            {
                return DesignerProperties.IsInDesignTool;
            }
        }

        private static IPrismViewLoadingService _prismViewLoadingService
        {
            get
            {
                if (IsDesignTime)
                {
                    return null;
                }
                return ServiceLocator.Current.GetInstance<IPrismViewLoadingService>();
            }
        }


        public bool Navigate(Uri source)
        {
            _prismViewLoadingService.LoadUrlToRegion(source.OriginalString, this.Name);
            return true;
        }
    }
}